package lab8;

import static org.junit.Assert.*;
import org.junit.Test;

public class LinkedListUnitTest {
	
	public static final Student s1 = new Student(1, "Ty");
	public static final Student s2 = new Student(2, "Suu");
	public static final Student s3 = new Student(3, "Dan");
	public static final Student s4 = new Student(4, "Meo");
	public static final Student s5 = new Student(5, "Thin");
	public static final Student s6 = new Student(6, "Ti");

	@Test
	public void testInit() {
		List<Student> list = new LinkedList<Student>();
		assertEquals("[]", list.toString());
	}
	@Test
	public void testAddFirst() {
		List<Student> list = new LinkedList<Student>();
		list.addFirst(s3);
		list.addFirst(s1);
		assertEquals("[1:Ty, 3:Dan]", list.toString());
	}
	@Test
	public void testAddLast() {
		List<Student> list = new LinkedList<Student>();
		list.addLast(s4);
		list.addLast(s6);
		assertEquals("[4:Meo, 6:Ti]", list.toString());
	}
	@Test
	public void testInsertAfter() {
		List<Student> list = new LinkedList<Student>();
		list.addLast(s4);
		list.addLast(s6);
		list.insertAfter(s4, s5);
		assertEquals("[4:Meo, 5:Thin, 6:Ti]", list.toString());
	}
	@Test
	//plz find error here
	public void testInsertBefore() {
		List<Student> list = new LinkedList<Student>();
		list.addLast(s1);
		list.addLast(s3);
		list.insertAfter(s3, s2);
		assertEquals("[1:A, 2:B, 3:C]", list.toString());
	}
	
	@Test
	//plz find error here
	public void testRemove() {
		List<Student> list = new LinkedList<Student>();
		list.addLast(s1);
		list.addLast(s2);
		list.addLast(s3);
		list.addLast(s4);
		list.remove(s3);
		assertEquals("[1:A, 2:B, 4:D]", list.toString());
	}
	@Test 
	//plz find error here
	public void testRemoveFirst() {
		List<Student> list = new LinkedList<Student>();
		list.addLast(s1);
		list.addLast(s2);
		list.addLast(s3);
		list.removeFirst();
		assertEquals("[2:B, 3:C]", list.toString());
	}
	@Test
	//plz find error here
	public void testRemoveLast() {
		List<Student> list = new LinkedList<Student>();
		list.addLast(s1);
		list.addLast(s2);
		list.addLast(s3);
		list.removeLast();
		assertEquals("[1:A, 2:B]", list.toString());
	}

}
